<?php
// +----------------------------------------------------------------------
// | ScrollPHP
// +----------------------------------------------------------------------
// | Copyright (c) 2010 Toojiong All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: LIZHEN
// +----------------------------------------------------------------------
// | $Id: ConfigFactory.class.php 2766 14-3-28 下午4:26 LIZHEN $
// +----------------------------------------------------------------------
// | Package Config

/**
 * 读取配置信息
 * @category ScrollPHP
 */
class ConfigFactory {

	public static function factory() {
        $usrConfigs = self::_usrConfig();
        $sysConfigs = self::_sysConfig();
        $configs = array();
        if($usrConfigs){
            $configs = array_merge($sysConfigs,$usrConfigs);    //合并数组
        } else {
            $configs = $sysConfigs;
        }
        return $configs;
	}

    private static function _usrConfig(){
        Logger::debug("加载应用配置 ：" . CONFIGS_PATH . '/config.php' );
        if(file_exists(CONFIGS_PATH . '/config.php')){
            return include CONFIGS_PATH . '/config.php';
        }else{
            Logger::debug("应用配置文件不存在！请检查文件".CONFIGS_PATH . '/config.php'."是否存在！");
            return null;
        }
    }

    private static function _sysConfig(){
        Logger::debug("加载系统配置");
        return include 'config.php';
    }

}